<?php
namespace app\controller;
use app\extensions\lib\Output;
use support\Log;
use support\Request;

class Oss
{

    public function download_oss_callback(Request $request){

        $data = $request->all();
        Log::channel('oss')->info('download_oss_callback'.':'.json_encode($data));
        return Output::success($data);
    }

    public function request_udid_oss_callback(Request $request){

        $data = $request->all();
        Log::channel('oss')->info('request_udid_oss_callback'.':'.json_encode($data));
        return Output::success($data);
    }

    public function test(Request $request){

        $callbackUrl = env('APP_URL').'oss/download_oss_callback';
        $request_id = 'tapplus_admin_uar_1677060819b27owe5qto';
        $ossPath = 'tapplus_push/push_udid/test/'.$request_id.'.csv';
        $param = ['request_id'=>$request_id];
        $Oss = new \app\extensions\api\Oss();
        $Oss->deleteObject($ossPath);
        $contents = [
            'uios_1645007607snk3x6baw5m0y4i0j'
        ];
        $url = $Oss::DOMAIN.'/'.$ossPath;
        $postition = $Oss->uploadContentsCallback($contents,$ossPath,$param,$callbackUrl);
        return Output::success(compact('postition','url','ossPath'));
    }

}